//
//  RTJUserInfoCell.m
//  RuiTaiJinProject
//
//  Created by jayson on 2018/12/1.
//  Copyright © 2018年 leewei. All rights reserved.
//

#import "RTJUserInfoCell.h"

@implementation RTJUserInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self backview:_bg_view1 viewOfcornerRadius:5];
    [self backview:_bg_view2 viewOfcornerRadius:5];
    
    [_btn addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn1 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn2 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn3 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn4 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn5 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn6 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn7 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn8 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];

    
    _btn7.layer.cornerRadius = _btn7.height/2;
    _btn7.layer.masksToBounds = YES;
    _btn7.layer.borderColor = [UIColor colorForHex:@"#FFBC04"].CGColor;
    _btn7.layer.borderWidth = 1;
    
    NSInteger idcardpassed = [RTJUserTool getTheUserModel].idcardpassed;
    NSString *name = [NSString stringWithFormat:@"%@",[RTJUserTool getTheUserModel].user_name];
    
    if (name.length==0 ||name == nil) {
        
        _username.text = idcardpassed ==1 ? [Apputil replaceStringWithAsterisk:[RTJUserTool getTheUserModel].real_name startLocation:1 lenght:[RTJUserTool getTheUserModel].real_name.length-1] :[Apputil replaceStringWithAsterisk:name startLocation:1 lenght:name.length-1] ;
    }else{
        
        _username.text = name;
    }
    
    _userImg.layer.cornerRadius = _userImg.width/2;
    _userImg.layer.masksToBounds = YES;
    
    NSString* avatarurl = [[NSUserDefaults standardUserDefaults] objectForKey:@"avatarurl"];
    
    [_userImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGURL,avatarurl.length!=0 ? avatarurl : [RTJUserTool getTheUserModel].avatar]] placeholderImage:[UIImage imageNamed:@"icon_yhid"]];
    
//    [_userImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGURL, [RTJUserTool getTheUserModel].avatar]] placeholderImage:[UIImage imageNamed:@"icon_yhid"]];

    
    NSString *phone = [NSString stringWithFormat:@"%ld",(long)[RTJUserTool getTheUserModel].mobile];
    _phone.text = [Apputil replaceStringWithAsterisk:phone startLocation:3 lenght:phone.length-7];
    _btn1.hidden = YES;
    
    
    _renzheng.text = [RTJUserTool getTheUserModel].idcardpassed == 1 ? [Apputil replaceStringWithAsterisk:[RTJUserTool getTheUserModel].real_name startLocation:1 lenght:[RTJUserTool getTheUserModel].real_name.length-1]:@"未认证";
    _btn2.hidden = [RTJUserTool getTheUserModel].idcardpassed == 1 ? YES : NO;
    
    
    _testType.text = [RTJUserTool getTheUserModel].is_risk == 1 ? @"已测评":@"未测评";
    
    NSString *paypassword = [RTJUserTool getTheUserModel].paypassword;
        _setLab.text = paypassword.length !=0 ? @"已设置":@"未设置";

}

-(void)setBankArr:(NSArray *)bankArr{
    
    _cardNum.text = bankArr.count != 0 ? @"已绑定":@"未绑定";
   

}

-(void)backview:(UIView *)backview viewOfcornerRadius:(NSInteger)cornerRadius{
    
    backview.layer.cornerRadius = cornerRadius;
    backview.layer.shadowColor = [UIColor colorForHex:@"#dbc9cc"].CGColor;
    backview.layer.shadowOffset = CGSizeMake(-1, 1);
    backview.layer.shadowOpacity = 0.5;
    backview.layer.shadowRadius = 5;
    
}

- (void)buttonOfTag:(UIButton *)sender {
    
    //    if (_delegate && [_delegate respondsToSelector:@selector(buttonOfTag:)]) {
    
    [self.delegate userInfobuttonOfTagsAction:sender.tag];
    
    //    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
